import { brandPageSelect } from '@/api/goodsInfo'
import { ref } from 'vue'

/**
 * 获取品牌下拉选项
 */
export const useGetBrandOptions = () => {
  // 品牌下拉选项
  const options = ref<Array<GoodBrandOption>>([])

  // 获取品牌下拉选项加载
  const loading = ref(false)

  // 获取品牌下拉选项请求参数
  const getBrandOptionsParam = ref({
    limit: 0,
    page: 0,
    name: '',
  })

  /**
   * 获取品牌下拉选项
   */
  const getBrandOptions = async () => {
    loading.value = true
    const res = await brandPageSelect(getBrandOptionsParam.value)
    loading.value = false
    options.value = res.data.data.rows
  }

  return {
    options,
    getBrandOptionsParam,
    loading,
    getBrandOptions,
  }
}
